.type ST_CTX, @function
.type LD_CTX, @function
.global ST_CTX, LD_CTX
ST_CTX:
	cli
	movl %edx, (20)(%eax)
	movl %ecx, (24)(%eax)
	movl %ebx, (28)(%eax)
	# save PC
	movl (%esp), %ecx
	movl %ecx, 0(%eax)
	# save ESP and other reg
    lea 4(%esp), %edx
    movl %edx, (4)(%eax)
	movl %ebp, (8)(%eax)
	movl %edi, (12)(%eax)
	movl %esi, (16)(%eax)
	movl $0, %eax
	sti
	ret

LD_CTX:
    cli
	# change ESP and other reg
	movl 4(%eax), %esp
	movl (8)(%eax), %ebp
	movl (12)(%eax), %edi
	movl (16)(%eax), %esi
	movl (20)(%eax), %edx
	movl (24)(%eax), %ecx
	movl (28)(%eax), %ebx
	# change PC
	movl (%eax), %ecx
	movl %ecx, (%esp)
	movl $1, %eax
	sti
	ret
